<template>
    <button 
    class="tm-button" 
    :class="[`tm-button--${type}`,{'is-plain':plain},{'is-round':round},{'is-circle':circle},{'is-disable':disable}]"
    :disabled="disable"
    @click="handleClick"
    >
        <span><slot></slot></span>
    </button>

</template>

<script>
export default {
    name:"TmButton",
    props:{
        type:{
            type:String,
            default:'',
        },
        plain:{
            type:Boolean,
            default:false
        },
        round:{
            type:Boolean,
            default:false,
        },
        circle:{
            type:Boolean,
            default:false
        },
        disable:{
            type:Boolean,
            default:false,
        }
    },
    created(){
        console.log(this.type)
    },
    methods:{
        handleClick(e){
            this.$emit('click',e)
        }
    }
}
</script>

<style lang="scss" scoped>
.tm-button{
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    // cursor: pointer;
    background-color: #fff;
    border:1px solid #dcdfed;
    color: #606266;
    -webkit-appearance: none;
    text-align: center;
    box-sizing:border-box;
    outline: none;
    margin: 0;
    transition:0.1s ;
    font-weight: 500;
    // 禁止文字被选中
    -moz-user-select: none;
    -ms-user-select:none;
    -webkit-user-select:none;

    padding: 12px 20px;
    font-weight: 14px;
    border-radius: 4px;
    &:hover{
        color: #409eff;
        background-color: #c6e2ff;
        background-color: #ecf5ff;
    }
    &:focus{
        color: #409eff;
        background-color: #c6e2ff;
        background-color: #ecf5ff;
    }
}

.tm-button--primary{
    color: #fff;
    background-color: #409eff;
    border-color: #409eff;

    &:hover,
    &:focus{
        background: #66b1ff;
        border-color: #66b1ff;
        color: #fff;
    }

}
.tm-button--success{
    color: #fff;
    background-color: #67c23a;
    border-color: #67c23a;

    &:hover,
    &:focus{
        background: #85ce61;
        border-color: #85ce61;
        color: #fff;
    }

}
.tm-button--warming{
    color: #fff;
    background-color: #e6a23c;
    border-color: #e6a23c;

    &:hover,
    &:focus{
        background: #ebb563;
        border-color: #ebb563;
        color: #fff;
    }

}
.tm-button--danger{
    color: #fff;
    background-color: #f56c6c;
    border-color: #f56c6c;

    &:hover,
    &:focus{
        background: #f78989;
        border-color: #f78989;
        color: #fff;
    }

}
.tm-button--info{
    color: #fff;
    background-color: #909399;
    border-color: #909399;

    &:hover,
    &:focus{
        background: #a6a9ad;
        border-color: #a6a9ad;
        color: #fff;
    }

}

// 镂空
.tm-button--primary.is-plain{
    color: #409eff;
    background: #ecf5ff;
    border-color: #b3d8ff;
     &:hover,
    &:focus{
        background: #409eff;
        border-color: #409eff;
        color: #fff;
    }
}

// 圆角
.tm-button.is-round{
    border-radius: 20px;
    padding: 12px 23px;
}

// 圆形
.tm-button.is-circle{
    border-radius: 50%;
    
}

// 禁用
.tm-button.is-disable{
    opacity: 0.4;
    cursor: not-allowed;
}



</style>